package com.xuecheng.media.api;

import com.xuecheng.base.model.RestResponse;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;

/**
 * 上传视频
 *
 * @author itcast
 */

@RestController
@Api(value = "大文件上传接口", tags = "大文件上传接口")
public class BigFilesController {

    @ApiOperation(value = "文件上传前检查文件")
    @PostMapping("/upload/checkfile")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "fileMd5", value = "文件md5信息", required = true, dataTypeClass = String.class)
    })
    public RestResponse<Boolean> checkfile(@RequestParam("fileMd5") String fileMd5) {
        return null;
    }

    @ApiOperation(value = "分块文件上传前的检测")
    @PostMapping("/upload/checkchunk")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "fileMd5", value = "文件md5信息", required = true, dataTypeClass = String.class),
            @ApiImplicitParam(name = "chunk", value = "分块序号", required = true, dataTypeClass = Integer.class)
    })
    public RestResponse<Boolean> checkchunk(@RequestParam("fileMd5") String fileMd5,
                                            @RequestParam("chunk") Integer chunk) {
        return null;
    }

    @ApiOperation(value = "上传分块文件")
    @PostMapping("/upload/uploadchunk")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "file", value = "文件", required = true, dataTypeClass = MultipartFile.class),
            @ApiImplicitParam(name = "fileMd5", value = "文件md5信息", required = true, dataTypeClass = String.class),
            @ApiImplicitParam(name = "chunk", value = "分块序号", required = true, dataTypeClass = Integer.class)
    })
    public RestResponse<Boolean> uploadchunk(@RequestParam("file") MultipartFile file,
                                             @RequestParam("fileMd5") String fileMd5,
                                             @RequestParam("chunk") Integer chunk) {
        return null;
    }

    @ApiOperation(value = "合并文件")
    @PostMapping("/upload/mergechunks")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "fileMd5", value = "文件md5信息", required = true, dataTypeClass = String.class),
            @ApiImplicitParam(name = "fileName", value = "文件名称", required = true, dataTypeClass = String.class),
            @ApiImplicitParam(name = "chunkTotal", value = "分块总数", required = true, dataTypeClass = Integer.class)
    })
    public RestResponse<Boolean> mergechunks(@RequestParam("fileMd5") String fileMd5,
                                             @RequestParam("fileName") String fileName,
                                             @RequestParam("chunkTotal") Integer chunkTotal) {
        Long companyId = 1232141425L;
        return null;
    }
}
